<#assign base=request.contextPath />
<!DOCTYPE html>
<div class="row">
	<div class="col-md-12 col-sm-12 col-xs-12">
		<div class="x_panel">
			<div class="x_title">
				<h2>票务添加 <small></small></h2>
				<div class="clearfix"></div>
			</div>
			<div class="x_content">
				<br/>
				<form id="postForm" data-parsley-validate class="form-horizontal form-label-left" method="post" action="${base}/gx/sysTicket/save">
					<input type="hidden" id="id" name="id" value="${((obj.id)?c)!0 }">
		            <input type="hidden" name="addTime" value="${(obj.addTime)!.now?string['yyyy-MM-dd HH:mm:ss']}">
		            <input type="hidden" name="updateTime" value="${.now?string['yyyy-MM-dd HH:mm:ss']}">
		           <input type="hidden" name="adminName" value="${(obj.adminName)!admin.userName}">
		            <input type="hidden" name="ticketState" value="${((obj.ticketState)?c)!0}">
	
					<#if obj??>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">添加票类型<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<select id="ticketType" name="ticketType" class="form-control select2">
                        		<option value="">请选择</option>
	                        	<#list listParent as parent>
	                        	<option value="${parent.id?c}" <#if (obj.ticketType.id==parent.id)>selected="selected"</#if>>${parent.ticketType}</option>
	                        	</#list>
	                    	</select>
                        </div>
					</div>
					<#else>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">添加票类型 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<select id="ticketType" name="ticketType" class="form-control select2">
                        		<option value="">请选择</option>
	                        	<#list listParent as parent>
	                        	<option value="${parent.id?c}">${parent.ticketType}</option>
	                        	</#list>
	                    	</select>
                        </div>
					</div>
					</#if>
					
				
			
			
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">票面截止日期 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="expirationDate" name="expirationDate" value="${(obj.expirationDate)!''}" class="form-control col-md-7 col-xs-12">
                        </div>
					</div>
						<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">票价(元)<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="price" name="price" value="${(obj.price)!''}" class="form-control col-md-7 col-xs-12">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">折扣 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="discount" name="discount" value="${(obj.discount)!''}" class="form-control col-md-7 col-xs-12">
                        </div>
					</div>
					
					<div class="form-group hideorshow" id="${(obj.id)!''}">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">添加张数 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="mummum" name="mummum" value="" class="form-control col-md-7 col-xs-12">
                        </div>
					</div>
					
					<div class="ln_solid"></div>
					<div class="form-group">
						<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
							<button type="button" class="btn btn-success" id="submit">保存</button>
							<button type="button" class="btn btn-primary" id="goBack">返回</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
$(function() {
//展示是否添加张数
     var check=$(".hideorshow").attr('id');
     if(check!=null&&check!=''){
    
      $(".hideorshow").hide();
     }else{
     $(".hideorshow").show();
     }
	//select2
	$(".select2").select2({width: "100%"});
	$('.summernote').summernote({
        height: 350, // set editor height
        minHeight: null, // set minimum height of editor
        maxHeight: null, // set maximum height of editor
        focus: false, // set focus to editable area after initializing summernote
        lang: 'zh-CN',
        shortcuts:false //禁止使用快捷键
    });
	 $('.dropify').dropify({
     	messages: {
		        'default': '点击或拖拽文件到这里',
		        'replace': '点击或拖拽文件到这里来替换文件',
		        'remove':  '移除文件',
		        'error':   '对不起，你上传的文件太大了',
		    }
     });
     // Used events
     drEvent = $('#icon_dropify').dropify();
     drEvent.on('dropify.afterClear', function(event, element) {
     	$("#infoIcon").val("");
     });

     drEvent.on('dropify.errors', function(event, element) {
         console.log('Has Errors');
     });

	$("#goBack").click(function() {
		$("#main_content").load('${base}/gx/sysTicket/list');	        
    });
	
	$("#submit").click(function() {
	
		var expirationDate=$.trim($("#expirationDate").val());
		var classifyId = $.trim($("#classifyId").val());
		var ticketCategory=$.trim($("#ticketCategory").val());
    
    	if(ticketType==""){
    		swal("请选择分类");
            return;
    	}
    	//获取数据

  
  
    
  
//        var url = "${base}/gx/infoContent/save";
//         $.post(url, $("#postForm").serialize(), function(data) {
//             if (data.flag) {
//             	swal(data.msg, "", "success");
//                 $("#main_content").load('${base}/gx/infoContent/list');
//             }else{
//             	swal(data.msg, "", "error");
//             }
//         });
        $("#postForm").ajaxSubmit(function(data) {
    	 	if (data.flag) {
    	 		swal(data.msg, "", "success");
				$("#main_content").load('${base}/gx/sysTicket/list');
    	 	} 
    	 	else {
    	 		swal(data.msg, "", "error");
    	 	}
    	});
	});
});
</script>